package com.xm_jd.controller.sy;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.xm_jd.model.dao.SyDao;
import com.xm_jd.model.entitys.GoodsDetailVO;
import com.xm_jd.model.entitys.leibie;
import com.xm_jd.utils.BaseServlet;

/**
 * Servlet implementation class Sy_lb
 */
@WebServlet("/Sy_lb")
public class Sy_lb extends BaseServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public Sy_lb() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		List<GoodsDetailVO> sp = new SyDao().getseleclt();
		List<GoodsDetailVO> xp = new SyDao().getselecltxp();
		if(sp.size()>0 && xp.size()>0){
			request.setAttribute("sp", sp);
			request.setAttribute("xp", xp);
		}
		
		List<leibie> a1 = new SyDao().getselectdt1();
		leibie a = a1.get(0);
		List<leibie> b1 = new SyDao().getselectdd1();
		
		List<leibie> a2 = new SyDao().getselectdt2();
		leibie a3 = a2.get(0);
		List<leibie> b2 = new SyDao().getselectdd2();
		
		List<leibie> a_3 = new SyDao().getselectdt3();
		leibie a4 = a_3.get(0);
		List<leibie> b3 = new SyDao().getselectdd3();
		
		List<leibie> a_4 = new SyDao().getselectdt4();
		leibie a5 = a_3.get(0);
		List<leibie> b4 = new SyDao().getselectdd4();
		
		if(a1.size()>0 && b1.size()>0){
			request.setAttribute("a", a);
			request.setAttribute("b1", b1);
			
			request.setAttribute("a3", a3);
			request.setAttribute("b2", b2);
			
			request.setAttribute("a4", a4);
			request.setAttribute("b3", b3);
			
			request.setAttribute("a5", a5);
			request.setAttribute("b4", b4);
		}
		//request.getRequestDispatcher("jsps/sy/sy.jsp").forward(request, response);
		this.forward("sy/sy");
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
